package cn.com.panda.view.camera;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.ImageView;

import androidx.annotation.Nullable;

/**
 * created by liujunlin on 2022/3/15 09:49
 */
public class GridView extends ImageView {

    private Paint linePaint = new Paint();

    public GridView(Context context) {
        super(context);
    }

    public GridView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }



    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        int width = getWidth();
        int height = getHeight();
        int averagew = width / 3;
        int averageh = height / 3;
        linePaint.setColor(Color.WHITE);
        linePaint.setStrokeWidth(1);
        for (int i = 0; i < 3; i++) {
            canvas.drawLine(0,i*averageh,width,i*averageh,linePaint);
        }
        for (int i = 0; i < 3; i++) {
            canvas.drawLine(i*averagew,0,i*averagew,height,linePaint);
        }

    }
}
